// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
 * @file NavSatFix.c
 * This source file contains the definition of the described types in the IDL file.
 *
 * This file was generated by the tool gen.
 */

#include "NavSatFix.h"

#include <ucdr/microcdr.h>
#include <string.h>






bool sensor_msgs_msg_NavSatFix_serialize_topic(ucdrBuffer* writer, const sensor_msgs_msg_NavSatFix* topic)
{
    bool success = true;

        success &= std_msgs_msg_Header_serialize_topic(writer, &topic->header);
        success &= sensor_msgs_msg_NavSatStatus_serialize_topic(writer, &topic->status);
        success &= ucdr_serialize_double(writer, topic->latitude);

        success &= ucdr_serialize_double(writer, topic->longitude);

        success &= ucdr_serialize_double(writer, topic->altitude);

        success &= ucdr_serialize_array_double(writer, topic->position_covariance, sizeof(topic->position_covariance) / sizeof(double));

        success &= ucdr_serialize_uint8_t(writer, topic->position_covariance_type);

    return success && !writer->error;
}

bool sensor_msgs_msg_NavSatFix_deserialize_topic(ucdrBuffer* reader, sensor_msgs_msg_NavSatFix* topic)
{
    bool success = true;

        success &= std_msgs_msg_Header_deserialize_topic(reader, &topic->header);
        success &= sensor_msgs_msg_NavSatStatus_deserialize_topic(reader, &topic->status);
        success &= ucdr_deserialize_double(reader, &topic->latitude);

        success &= ucdr_deserialize_double(reader, &topic->longitude);

        success &= ucdr_deserialize_double(reader, &topic->altitude);

        success &= ucdr_deserialize_array_double(reader, topic->position_covariance, sizeof(topic->position_covariance) / sizeof(double));

        success &= ucdr_deserialize_uint8_t(reader, &topic->position_covariance_type);

    return success && !reader->error;
}

uint32_t sensor_msgs_msg_NavSatFix_size_of_topic(const sensor_msgs_msg_NavSatFix* topic, uint32_t size)
{
    uint32_t previousSize = size;
        size += std_msgs_msg_Header_size_of_topic(&topic->header, size);
        size += sensor_msgs_msg_NavSatStatus_size_of_topic(&topic->status, size);
        size += ucdr_alignment(size, 8) + 8;

        size += ucdr_alignment(size, 8) + 8;

        size += ucdr_alignment(size, 8) + 8;

        size += ucdr_alignment(size, 8) + sizeof(topic->position_covariance);

        size += ucdr_alignment(size, 1) + 1;

    return size - previousSize;
}
